<?
require("curl_http.php");
$username = $_GET['u'];
$result = Check2k2($username);
if ($result == "no") {
    $result = Check5w5($username);
}
echo $result;

function Check2k2($username)
{
    $site = "http://2k2.com/index.php/ajax?t=" . time();
    $curl = & new Curl_HTTP_Client();
    $curl->store_cookies("/cookies.txt");
    $curl->set_user_agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
    $curl->set_referrer("http://2k2.com/reg");
    $html_date = $curl->fetch_url("" . $site . "", "", 10);
    if ($html_date == "") {
        return "no";
    }
    $login = array();
    $login['operation'] = "checkUser";
    $login['username'] = $username;
    $html_date = $curl->send_post_data("" . $site . "", $login, "", 10);
    //echo $html_date;exit;
    $fileString = json_decode($html_date);
    $status = $fileString->status;
    $info = $fileString->info;
    if ($status == 1) {
        return "yes";
    } else {
        return "no";
    }
}

function Check5w5($username)
{
    $site = "http://www.5w5.com/SyncInit/checkUser";

    $curl = & new Curl_HTTP_Client();
    $curl->store_cookies("/cookies.txt");
    $curl->set_user_agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
    $curl->set_referrer("" . $site . "");
    $html_date = $curl->fetch_url("" . $site . "", "", 10);
    $login = array();
    $login['UserDesc'] = "ValidUserID";
    $login['username'] = $username;
    $html_date = $curl->send_post_data("" . $site . "", $login, "", 10);
    $fileString = json_decode($html_date);
    $uid = $fileString->data;

    $site = "http://www.5w5.com/SyncTimer/obtain";
    $status = 2;
    $cc = 0;
    while ($status == 2 && $cc < 5) {
        sleep(3);
        $login = array();
        $login['token'] = $uid;

        //echo "token=$uid";
        $html_date = $curl->send_post_data("" . $site . "", $login, "", 10);
        $fileString = json_decode($html_date);
        $status = $fileString->status;
        //echo $cc."->status:" .$status."<br>";
        $cc += 1;
        //echo $html_date."<br>";
    }
    if ($status == 1) {
        return "yes";
    } else {
        return "no";
    }
}

?>
